<?
echo "<table cellpadding=0 cellspacing=4 border=0 style='border-left: 1px solid black; border-bottom: 1px solid black;'>";
echo "<tr><td colspan=2><h1>Timesheet</h1>";

inc_inclib("html.php");
inc_inclib("query.php");

echo "<form id='timesheet' action='$myurl/timesheet/update.php' target='timesheet'  style='padding-top:0px;padding-bottom:0px;margin-top:0px;margin-bottom:0px;'>";

if ($pid) {
echo "<tr><td>Client<td>";
$ce = $db->query1("select * from client where id = ".$db->sqlint($pe["client_id"]));
echo "{$ce["title"]}";
echo "<input type='hidden' name='client_id' value='{$pe["client_id"]}'>";
}

#echo "<input type='hidden' name='project_id' value = '$pid'>";
echo "<tr><td>Project<td>";
$projects=query2map($db->query("select * from project order by title"),"id","title");
echo "<select name='project_id' onchange='window.location=\"$myurl/projects/\"+this.value+\"/\";'>";
echo "<option value=''>-- Choose --";
foreach ($projects as $k=>$v) {
	$c = ($k == $pid?"selected":"");
	echo "<option value='$k' $c>$v";
	}
echo "</select>";

if ($pid) {
echo "<tr><td>Module<td>";
$modules=query2map($db->query("select id,title from modules where project_id = $pid or id < 0 order by title"),"id","title");
echo html_option_array("select","modules_id",$modules);
echo "<tr><td>Time<td><input type='text' name='timestart' size=6 value='{$_SESSION["timecard_timestart"]}'> - ";
echo "<input type='text' name='timeend' size=6>";
echo "<tr><td>Hours<td><input type='text' name='hours' size=4>";
echo "<tr><td>Description<td><textarea name='description' rows=3 cols=20></textarea>";
echo "<tr><td>Billable<td><input type='checkbox' name='billable' value='1'> ";
echo "Rate <input type='text' name='rate' value='{$pe["rate"]}' size=4>";
echo "<tr><td><td><input type='button' value='Log' onclick='window.open(\"\",\"timesheet\",\"width=500,height=300\");form.submit();'>";
} else echo "<tr><td><td>";
echo " <input type='button' value='View' onclick = 'window.open(\"$myurl/timesheet/index.php\",\"timesheet\",\"width=500,height=300\");'>";

echo "</form>";
echo "</table>";
?>